﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using ShuiLing.Application.Test;
using ShuiLing.Domain.Shared;
using ShuiLing.Presentation.Endpoint.Abstractions;

namespace ShuiLing.Presentation.Endpoint.UserController;

[Route("api/user")]
public sealed class UserController : ApiController
{
    public UserController(ISender sender) : base(sender)
    {
    }

    [HttpGet]
    public async Task<IActionResult> Test(CancellationToken cancellationToken = default)
    {
        var testCommand = new TestCommand("Lisi");
        Result<User> result = await Sender.Send(testCommand, cancellationToken);
        if (result.IsFailure)
        {
            return HandleFailure(result);
        }

        return Ok(result);
    }
}
